name: Lighthouse

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
    paths:
      - 'frontend/**'

jobs:
  lighthouse:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Setup Node.js environment
        uses: actions/setup-node@v2
        with:
          node-version: 19

      - name: Install dependencies
        run: npm ci
        working-directory: frontend

      - name: Build frontend
        run: CI=false npm run build
        working-directory: frontend

      - name: Run Lighthouse CI
        run: |
          npm install -g @lhci/cli
          lhci autorun
        working-directory: frontend
